﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KabiManagementWeb.Models;
namespace KabiManagementWeb.Controllers
{
    public class TipController : Controller
    {
        KBManagementDataContext context = DBUtils.GetContext(DBUtils.DBType.Local);
        //
        // GET: /Tip/

        public ActionResult Index()
        {
            return View(context.Percent_Tips);
        }

        //
        // GET: /Tip/Details/5

       
        //
        // GET: /Tip/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View(context.Percent_Tips.Single(x=>x.Pt_Id.Equals(id)));
        }

        //
        // POST: /Tip/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, Percent_Tip collection)
        {
            try
            {
                // TODO: Add update logic here
               var tp= context.Percent_Tips.Single(x => x.Pt_Id.Equals(id));
               tp.Tip_Percent_Receive = collection.Tip_Percent_Receive;
               context.SubmitChanges();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        
    }
}
